/**
 * Created by Administrator on 2018/3/26.
 */
(function (w) {
    var events = {};

    function on(name, cb) {
        var temp = events[name];
        if (!temp) {
            events[name] = temp = [];
        }
        temp.push(cb);
    }

    function emit(name, args) {
        var temp = events[name];
        if (!temp) {
            return;
        }
        temp.forEach(function (cb) {
            cb(args);
        });
    }

    w.MyEvent = w.$e = {
        on: on,
        emit: emit
    }
})()